package com.ziiwee.reduce.describe.types;

import com.ziiwee.reduce.describe.types.parser.DefaultFieldDescribeParser;
import com.ziiwee.reduce.describe.types.parser.DefaultTypeDescribeParser;
import com.ziiwee.reduce.describe.types.parser.FieldDescribeParser;
import com.ziiwee.reduce.describe.types.parser.TypeDescribeParser;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ziiwee
 * @data 2020/8/12
 */
public class DefaultTypeProviderRegister implements TypeProviderRegister {

    protected List<TypeProvider> providers = new ArrayList<>();
    protected TypeDescribeParser typeDescribeParser = new DefaultTypeDescribeParser();
    protected FieldDescribeParser fieldDescribeParser = new DefaultFieldDescribeParser();


    @Override
    public void setDefaultTypeDescribeParser(TypeDescribeParser typeDescribeParser) {
        this.typeDescribeParser = typeDescribeParser;
    }

    @Override
    public void setDefaultFieldDescribeParser(FieldDescribeParser fieldDescribeParser) {
        this.fieldDescribeParser = fieldDescribeParser;
    }

    @Override
    public TypeDescribeParser getDefaultTypeDescribeParser() {
        return this.typeDescribeParser;
    }

    @Override
    public FieldDescribeParser getDefaultFieldDescribeParser() {
        return this.fieldDescribeParser;
    }

    @Override
    public void setProviders(List<TypeProvider> providers) {
        this.providers = providers;
    }

    @Override
    public void registerProvider(TypeProvider provider) {
        this.providers.add(provider);
    }

    @Override
    public void registerProvider(int index, TypeProvider provider) {
        this.providers.add(index, provider);
    }

    @Override
    public List<TypeProvider> getProviders() {
        return providers;
    }
}
